<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="csrf-token" content="{{ csrf_token() }}">
    <title>{{ Admin::title() }} @if($header) | {{ $header }}@endif</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    {!! Admin::css() !!}

    {!! Admin::headerJs() !!}
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

</head>
{!! Admin::style() !!}
<body class="layui-layout-body {{config('admin.skin')}} {{join(' ', config('admin.layout'))}}">
<div class="layui-layout layui-layout-admin">
    @include('admin/partials/header')
    @include('admin.partials.sidebar')
    <div class="layui-body">
        <!-- 内容主体区域 -->
        @yield('content')
    </div>

    {!! Admin::html() !!}
    @include('admin.partials.footer')

</div>

<script>
    function LA() {}
    LA.token = "{{ csrf_token() }}";
    LA.user = @json($_user_);
</script>

<!-- REQUIRED JS SCRIPTS -->
{!! Admin::js() !!}
{!! Admin::script() !!}
<script>
    //由于模块都一次性加载，因此不用执行 layui.use() 来加载对应模块，直接使用即可：
    ;!function(){
        var layer = layui.layer
            ,form = layui.form
            ,table = layui.table;
        function GetQueryString(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if(r!=null)return  unescape(r[2]); return null;
        }

        var mpi = GetQueryString('mpi');
        if (mpi) {
            var mpi_arr = mpi.split('-')
            var parent_mpi = mpi_arr[0] + '-' + mpi_arr[1]
            if (mpi != parent_mpi) {
                console.log(parent_mpi)
                $('.layui-nav').find('[data-mpi=' + parent_mpi + ']').parent().addClass('layui-nav-itemed');
                $('.layui-nav').find('[data-mpi=' + mpi + ']').addClass('layui-this');
            } else {
                $('.layui-nav').find('[data-mpi=' + mpi + ']').addClass('layui-this');
            }
        }
        // console.log(mpi_arr)

        /**
         * 菜单栏缩放
         */
        $('body').on('click', '[data-mpi]', function () {
            var mpi = $(this).attr('data-mpi')
            var href = $(this).attr('data-href')
            if (href) {
                if (href.indexOf("?") > -1) {
                    href = href + '&mpi=' + mpi;
                } else {
                    href = href + '?mpi=' + mpi;
                }
                window.location.href = href
            }
        });
    }();
</script>
</body>
</html>
